﻿@using System.Data;
@using System.Web;
@using DTcms.Web.MVC.Areas.Web.Controllers;
@using DTcms.Web.MVC.UI.Controllers;
@using DTcms.Model;
@{
   Layout = "~/Areas/Web/Views/" + ViewBag.TemplateSkin + "/Shared/_LayoutList.cshtml";
   DTcms.Model.sites site = ViewData["site"] as DTcms.Model.sites;
   DTcms.Model.sysconfig config = ViewData["sysConfig"] as DTcms.Model.sysconfig;
   Article_ListController bc = ViewBag.BasePage as Article_ListController;
   DTcms.Model.article_category m = ViewData["model"] as DTcms.Model.article_category;
   ViewBag.Title = m.title + " - " + site.name;
   string channel = "goods";
   int category_id = int.Parse(ViewBag.CategoryId as string);
   int pagesize = 20;
   int totalcount = 0;
   string pagelist = string.Empty;
   int page = int.Parse(ViewBag.Page as string);
   DataTable categoryList = bc.get_category_child_list(channel, 0);//商品分类  
   DataTable goodsList = bc.get_article_list(channel, category_id, pagesize, page, "status=0", out totalcount, out pagelist, "goods_list", category_id, "__id__");<!--取得一个分页DataTable-->
}

<!--当前位置-->
@{string category_nav=bc.get_category_menu("goods_list", category_id);}
<div class="section">
    <div class="location">
        <span>当前位置：</span>
        <a href="@bc.linkurl("index")">首页</a> &gt;
        <a href="@bc.linkurl("goods")">购物商城</a>
        @Html.Raw(category_nav)
    </div>
</div>
<!--/当前位置-->

<!--分类导航-->
<div class="section">
  <div class="wrapper clearfix">
    <div class="screen-box">
      <dl>
        <dt>分类：</dt>
        <dd>
         <a class="@(category_id==0 ? "selected" : "")" href="@bc.linkurl("gsearch")">全部</a>
         @foreach(DataRow cdr in categoryList.Rows){
            <a class="@(category_id==Convert.ToInt32(cdr["id"]) ? "selected" : "")" href="@bc.linkurl("gsearch","?category_id=" + cdr["id"])">@cdr["title"]</a>
         }
        </dd>
      </dl>

      @{ DataTable specList=bc.get_article_category_spec(m.id);}
      @foreach(DataRow dr1 in specList.Rows){
      <!--规格列表-->
      <dl>
         <dt>@dr1["title"]：</dt>
         <dd>
            @{DataTable subList=bc.get_article_spec_child((int)dr1["id"]);}
            <a class="selected" href="@bc.linkurl("gsearch")">全部</a>
            @foreach(DataRow dr2 in subList.Rows){
            <a href="@bc.linkurl("gsearch","?category_id="+category_id+"&s_"+dr1["id"]+"="+dr2["id"])">@dr2["title"]</a>
            }
         </dd>
      </dl>
      }
      <!--/规格列表-->
      <dl>
        <dt>价格：</dt>
        <dd>
          <a class="selected" href="@bc.linkurl("gsearch")">全部</a>
          <a href="@bc.linkurl("gsearch","?category_id="+category_id+"&min_price=0&max_price=100")">0-100元</a>
          <a href="@bc.linkurl("gsearch","?category_id="+category_id+"&min_price=101&max_price=500")">101-500元</a>
          <a href="@bc.linkurl("gsearch","?category_id="+category_id+"&min_price=501&max_price=1000")">501-1000元</a>
          <a href="@bc.linkurl("gsearch","?category_id="+category_id+"&min_price=1001&max_price=2000")">1001-2000元</a>
          <a href="@bc.linkurl("gsearch","?category_id="+category_id+"&min_price=2000")">2000以上</a>
        </dd>
      </dl>  
    </div>

    <div class="line15"></div>
    <div class="sort-box">
      <a class="first selected" href="@bc.linkurl("gsearch","?category_id="+category_id+"&orderby=time")">上架时间</a>
      <a href="@bc.linkurl("gsearch","?category_id="+category_id+"&orderby=click")">按人气</a>
      <a href="@bc.linkurl("gsearch","?category_id="+category_id+"&orderby=max")">价格从高到低</a>
      <a href="@bc.linkurl("gsearch","?category_id="+category_id+"&orderby=min")">价格从低到高</a>
    </div>
 
  </div>
</div>
<!--/分类导航-->

<!--商品列表-->
<div class="section">
<div class="wrapper clearfix">

      <ul class="img-list">
        @foreach(DataRow dr in goodsList.Rows){
        <li>
          <a title="@dr["title"]" href="@bc.linkurl("goods_show",dr["id"])">

            <div class="img-box">
                @if(dr["is_red"].ToString()=="1"){
                <div class="abs-txt">推荐</div>
                }
                <img src="@dr["img_url"]" />
            </div>
            <div class="info">
              <h3>@dr["title"]</h3>
              <div class="price">
                <b>￥@dr["sell_price"]</b>元
              </div>
              <p>
                <strong>库存：@dr["stock_quantity"]件</strong>
                <span>市场价：<s>@dr["market_price"]</s></span>
              </p>
            </div>

            </a>
        </li>
        }
      </ul>

    <!--页码列表-->
    <div class="page-box">
      <div class="digg">@Html.Raw(pagelist)</div>
    </div>
    <!--/页码列表-->
  </div>
</div>
<!--/商品列表-->